program define fx1, rclass
   version 15.1
	syntax varlist [if] [pweight], t1(varname) [OPTS(str) ALLFIVE NODRAW]
	marksample touse
	
	if "`weight'" ~= "" {
	   local wt [`weight'`exp']
   }			
	
	table axn5 `t1' if `touse' `wt', c(mean `varlist' n `varlist') format(%6.4f)
	
	tempname fx
	local gopts scheme(s1mono) plotregion(style(none)) mlabel format(%3.0f)
			
	* Distinguish all five actions
	if "`allfive'" ~= "" {
		reg `varlist' i.axn5##i.`t1' if `touse' `wt', robust
		margins r.`t1', at(axn5=(0 1 2 3 4))		
		mat `fx' = r(table)
		mat colnames `fx' = c0 c1 c2 c3 c4
		if "`nodraw'" == "" {
		   coefplot ///
			   (matrix(`fx'[1,]), ci("`fx'[5,] `fx'[6,]") msymbol(O) mlabpos(10)),  ///
				coeflabel(c0="No Action" c1="Cut 5%, Cost 10%" c2="Cut 5%, Cost 4%" ///
               c3="Cut 25%, Cost 10%" c4="Cut 25%, Cost 4%") `gopts' `opts'
		}
   }
	else {
	
		* Estimates if no action
		reg `varlist' i.`t1' if `touse' & axn5==0 `wt', robust
		margins r.`t1'
		mat `fx' = r(table)		
		
		* Estimates if axn = 5% reduction in emissions. Average over prices
		reg `varlist' i.axn5#i.`t1' if `touse' & (axn5==1 | axn5==2) `wt', robust
		margins r.`t1', asbalanced // equal weight over prices
		mat `fx' = `fx', r(table)		
		
		* Estimates if axn = 25% reduction in emissions. Average over prices.
		reg `varlist' i.axn5#i.`t1' if `touse' & (axn5==3 | axn5==4) `wt', robust
		margins r.`t1', asbalanced // equal weight over prices
		mat `fx' = `fx', r(table)
		
		mat colnames `fx' = none low high
		
		if "`nodraw'" == "" {
		   coefplot ///
			   (matrix(`fx'[1,]), ci("`fx'[5,] `fx'[6,]") msymbol(O) mlabpos(10)), ///
			   coeflabel(none = "No Action" low = "Cut 5%" high = "Cut 25%") ///
			   `gopts' `opts' 
		}
		
	}
	
	mat list `fx'	
	return matrix fx = `fx'
	
end
